#ifndef CVS_THREAD_H_
#define CVS_THREAD_H_
#include "Atomic.h"
#include <string>
#include <boost/function.hpp>

namespace cvs {
	class Thread : boost::noncopyable {
	public:
		typedef boost::function<void()> threadFun;
	
	public:
		explicit Thread(const threadFun& f, const std::string name=std::string());
		~Thread();

		void start(void);
		void join(void);

		bool started(void) const { return started_; }
		bool joined(void) const { return joined_; }

		static int numCreated(void) { return numCreated_.get(); }

	private:
		bool started_;
		bool joined_;
		boost::thread threadId_;
		threadFun func_;
		std::string name_;

		static AtomicInt32 numCreated_;
	};
}

#endif